﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YJKArchUtils.Utils;
using YJKRevitBase.WinForm;
using YJKRevitView;
using YJKRevitParapet.Controller;

namespace YJKRevitParapet
{
	[Transaction(TransactionMode.Manual)]
	[Regeneration(RegenerationOption.Manual)]
	public class CmdManualCreateParapets : IExternalCommand
	{
		public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elems)
		{
			CmdViewType types = CmdViewType.FloorPlan;
			if (SwitchView.SetUsableView(types, cmdData) != Autodesk.Revit.UI.Result.Succeeded)
			{
				return Autodesk.Revit.UI.Result.Failed;
			}
			HideWarningAndErroringKit @object = new HideWarningAndErroringKit(new List<string>
			{
				"Create parapet"
			}, HideWarningAndErroringKit.HideKitEnum.HideErroring);
			cmdData.Application.Application.FailuresProcessing += @object.OnFailuresProcessing;
			if (CreateParapetController._hWndRevit == null)
			{
                CreateParapetController._hWndRevit = new WindowHandle(Process.GetCurrentProcess().MainWindowHandle);
			}
			return new CreateParapetController(cmdData).ManualCreateParapets();
		}
	}
}
